package com.hwg.shiliupro.po;
import lombok.Data;

@Data
public class R {
    private Integer code;
    private Object data;
    private String message;

    public R(){}

    // 成功
    public static R ok(){
        R rs = new R();
        rs.setCode(200);
        rs.setMessage("成功");
        return rs;
    }

    // 失败
    public static R error(){
        R rs = new R();
        rs.setCode(201);
        rs.setMessage("失败");
        return rs;
    }

    //其实就是和setter方法类似   只是它有返回值为R 即它本身(导致支持链式编程)
    public R code(int code){
        this.setCode(code);
        return this;
    }

    public R message(String message){
        this.setMessage(message);
        return this;
    }

    public R data(Object data){
        this.setData(data);
        return this;
    }

}
